<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      
    </style>
</head>
<body>
   <button>胡歌</button>
   <button>赵玉真</button> 
   <button>彭于晏</button>
   <button>萧瑟</button>
   <button>无心</button>
   <script>
    var btn=document.getElementsByTagName('button')
    for(let i=0;i<btn.length;i++){
        btn[i].onclick=function(){
            // 首先全部去掉
            for(let j=0;j<btn.length;j++){
                btn[j].style.backgroundColor=''
            }
            // 然后在赋值属性
            btn[i].style.backgroundColor='pink'
        }
    }
   </script>
</body>
</html>